<!-- 户型 -->
<template>
  <view class="unit-type">
    <view class="filterTags">
      <span v-for="(item, index) in filterTags" :key="index" :class="['filter-item', item.select ? 'active-item' : '']" @click="handleFilterTags(index)">
        {{ item.title }}
      </span>
    </view>
    <view class="unit-type-card" v-for="(item, index) in list" :key="index" @click="handleDetail(item)">
      <view class="left">
        <image :src="item.roomTypeCover" alt="" />
        <image class="icon" :src="$CDN('/customer/static/images/icons/has-video.png')" alt="" />
      </view>
      <view class="right">
        <view class="roomTypeTitle">{{ item.roomTypeTitle }}</view>
        <view class="detail">{{ item.detail }}</view>
        <view class="tags">
          <view v-for="(items, indexs) in item.tags" :key="indexs"> {{ items }}</view>
        </view>
        <view class="showPrice">{{ item.showPrice }} <span>元/间/月</span> </view>
      </view>
    </view>
  </view>
</template>

<script>
import { mapActions, mapGetters } from 'vuex'

export default {
  name: 'componentName',
  components: {},
  mixins: [],
  props: {
    filterTags: {
      type: Array,
      default: () => [],
    },
    list: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {}
  },
  // 侦听属性
  watch: {},
  // 计算属性
  computed: {
    ...mapGetters([]),
  },
  // 监听页面加载，该钩子被调用时data,computed,function,watch,props,slots已设置完成
  onLoad(options) {},
  // 监听页面显示，页面每次出现在屏幕上都触发
  onShow() {},
  // 监听页面初次渲染完成，此时组件已挂载完成
  onReady() {},
  // 下拉刷新
  onPullDownRefresh() {},
  // 加载更多
  onReachBottom() {},

  created() {},
  mounted() {},
  destroyed() {},
  methods: {
    ...mapActions([]),
    handleFilterTags(index) {
      this.$emit('emit-changeTag', index)
    },
    handleDetail({ roomTypeId }) {
      const { projectId } = this.$Route.query
      this.$ROUTE.go('/pages/subpackage/housing-resources/room-detail/index', { room_id: '', roomTypeId, projectId })
    },
  },
}
</script>

<style lang="scss" scoped>
.unit-type {
  background: white;
  padding: 0 16rpx 32rpx;
  margin: 0 16rpx;
  .filterTags {
    display: flex;
    flex-wrap: wrap;
    padding-top: 32rpx;
    background: white;
    padding: 16rpx 0rpx;
    .filter-item {
      padding: 8rpx 24rpx;
      font-size: 24rpx;
      background-color: #f5f5f5;
      color: #666;
      border-radius: 16rpx;
      margin-right: 16rpx;
      margin-bottom: 16rpx;
      display: flex;
      align-items: center;
    }
    .active-item {
      background: #edf5f9;
      color: $uv-primary;
      font-weight: bold;
    }
  }
  .unit-type-card {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    margin-bottom: 20rpx;
    .left {
      width: 240rpx;
      height: 180rpx;
      background: #fff3eb;
      position: relative;
      border-radius: 16rpx;
      overflow: hidden;
      image {
        width: 100%;
        height: 100%;
      }
      .icon {
        width: 40rpx;
        height: 40rpx;
        position: absolute;
        left: 16rpx;
        top: 16rpx;
      }
    }
    .right {
      margin-left: 16rpx;
      margin-top: 8rpx;
      .roomTypeTitle {
        font-weight: bold;
        color: #222222;
        font-size: 28rpx;
        line-height: 40rpx;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .detail {
        font-weight: 400;
        line-height: 32rpx;
        color: #666666;
        font-size: 22rpx;
        width: 400rpx;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .tags {
        display: flex;
        flex-wrap: wrap;
        view {
          padding: 2rpx 8rpx;
          font-size: 22rpx;
          font-weight: 400;
          background-color: #f5f5f5;
          color: #999;
          border-radius: 8rpx;
          margin-top: 8rpx;
          margin-right: 8rpx;
        }
      }
      .showPrice {
        font-size: 32rpx;
        font-weight: bold;
        color: $uv-price-primary;
        line-height: 32rpx;
        padding-right: 4rpx;
        margin-top: 10rpx;
        span {
          margin-left: 8rpx;
          font-size: 20rpx;
          color: #999999;
        }
      }
    }
  }
}
</style>
